import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { registerStore } from '@/stores/register'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import { i18n } from './i18n'

import '@/styles/index.scss'
// 引入和风天气图标
import 'qweather-icons/font/qweather-icons.css'
const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
// 注册 Pinia
registerStore()

const requireModules = import.meta.glob('./template/*/*/*.vue', { eager: true })
for (const path in requireModules) {
  const result: any = path.match(/.\/(\w+).vue$/)
  const modulesConent: any = requireModules[path]
  //app.component(result[1], defineAsyncComponent(modulesConent))
  app.component(result[1], modulesConent.default)
  //console.log('全局组件注册：', result[1], modulesConent.default)
}

app.use(router)
app.use(i18n)
app.use(ElementPlus)
app.mount('#app')
